package com.guet.news_main.listener;

import com.guet.news_main.entity.NewsArticle;
import com.guet.news_main.util.RedisUtil;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @Classname RabbitMQListener
 * @Description TODO
 * @Date 2022/1/6 11:22
 * @Author csp
 */
@Component
public class RabbitMQListener {
    @Autowired
    private RedisUtil redisUtil;
    @RabbitListener(queues = "boot_queue")
    /* @RabbitListener(queues = "boot_queue",autoStartup = "false",id="1")*/
    public void ListenerQueue(Message message, NewsArticle newsArticle){
        //将新闻存储到redis，一天过期，完成每日推荐的功能
        redisUtil.lSet("newsList",newsArticle,60*60*24);
    }
}